#include <iostream>
#include<algorithm>
using namespace std;
int a[100010], b[10];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[a[i]]++;
    }
    sort(b + 1, b + 10);
    if (b[9] - b[1] <= 1) 
        cout << "YES";
    else 
        cout << "NO";
    return 0;
}